package ejemplosAR;

import processing.core.PApplet;
import processing.core.PVector;
import processing.video.*;
import jp.nyatla.nyar4psg.*;

public class MarkerPlane extends PApplet{

	private static final long serialVersionUID = 1L;
	private static final String PARA = "/Users/marthagarzon/Desktop/Juan Manuel/Workspace/ModuloSimulacion/data/camera_para.dat";
	private static final String HIRO = "/Users/marthagarzon/Desktop/Juan Manuel/Workspace/ModuloSimulacion/data/patt.hiro";

	private Capture cam;
	private MultiMarker nya;

	public void setup() {
		size(640,480,P3D);
		colorMode(RGB, 100);
		cam=new Capture(this,640,480);
		nya=new MultiMarker(this,width,height,PARA,NyAR4PsgConfig.CONFIG_PSG);
		nya.addARMarker(HIRO,80);//id=0
	}

	int c=0;
	public void draw()
	{
		c++;
		if (cam.available() !=true) {
			return;
		}
		cam.read();
		nya.detect(cam);
		background(0);
		nya.drawBackground(cam);
		if(nya.isExistMarker(0))
		{
			PVector p=nya.screen2MarkerCoordSystem(0,mouseX,mouseY);
			nya.beginTransform(0);
			noFill();
			stroke(100,0,0);
			rect(-40,-40,80,80);
			stroke(100,100,0);
			ellipse((int)p.x,(int)p.y,20-c%20,20-c%20);
			nya.endTransform();
		}
	}
}